Skip to content

Conversation

@n-issei-777
Copy link

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:
Problem:
Currently, load_artifact_tool does not support common spreadsheet MIME types such as .xlsx, .xls, and .ods. As discussed in the community discussion #3450, when users upload these files via the ADK Web, the tool fails to load them. This forces users to implement redundant custom parsing logic in before_agent_callback to handle these files manually.

Solution:
I have added the following spreadsheet MIME types to _SPREADSHEET_MIME_TYPES to ensure they are correctly identified:

  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.xlsx)
  • application/vnd.ms-excel (.xls)
  • application/vnd.oasis.opendocument.spreadsheet (.ods)

With this change, the tool can now successfully read these files and convert their content into Markdown format. This allows the LLM to process spreadsheet data more effectively. Furthermore, it is capable of handling files with multiple sheets, converting each sheet into its own Markdown table.

Testing Plan

I verified the fix using a local test agent (agent.py) that utilizes load_artifact_tool.
Uploaded .xlsx, .xls and, .ods files and confirmed it is now correctly recognized by the tool.
Verified that the agent can access the artifact data without needing manual parsing in callbacks.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
# Updated unit tests (I've updated test_load_artifacts_tool.py to test this fix)
$ uv run pytest ./tests/unittests/tools/test_load_artifacts_tool.py
================================================================== warnings summary ==================================================================
tests/unittests/tools/test_load_artifacts_tool.py::test_get_declaration_with_json_schema_feature_enabled
  /Users/issein/Desktop/01_work/30_PJ/003_auspost/load_artifact_pr/adk-python/tests/unittests/tools/test_load_artifacts_tool.py:170: UserWarning: [WIP] feature FeatureName.JSON_SCHEMA_FOR_FUNC_DECL is enabled.
    declaration = load_artifacts_tool._get_declaration()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================ 8 passed, 1 warning in 2.00s ==========================================================
# All unit tests
$ uv run pytest ./tests/unittests
============================================= 4173 passed, 1 skipped, 2039 warnings in 111.96s (0:01:51) =============================================

Manual End-to-End (E2E) Tests:
Each file content can now be read by load_artifact_tool as shown below. The tool can successfully process and load data from all available sheets when multiple sheets exist.
.xlsx file
Screenshot 2026-02-10 at 13 34 15
.xls file
Screenshot 2026-02-10 at 13 39 40
.ods file*
Screenshot 2026-02-10 at 13 37 44

One of the test file is below.d
test_ss.xlsx

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Without this fix, load_artifact_tool cannot read the contents of uploaded .xlsx, .xls, or .ods files.
Screenshot_1

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @n-issei-777, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the load_artifact_tool by enabling it to natively handle various spreadsheet file formats. Previously, users had to implement custom solutions to process these files, leading to inefficiencies. With this change, the tool can now automatically parse and convert spreadsheet content into a structured Markdown format, making it directly consumable by large language models and significantly improving data handling capabilities for spreadsheet-based artifacts.

Highlights

  • Spreadsheet Support: Added support for common spreadsheet MIME types (.xlsx, .xls, .ods) to the load_artifact_tool, allowing it to parse and convert spreadsheet data into Markdown format for LLM processing.
  • Dependency Updates: Introduced new Python dependencies (openpyxl, pandas, odfpy, xlrd, tabulate) to enable robust spreadsheet parsing and Markdown table generation.
  • Multi-Sheet Handling: The tool can now process spreadsheets with multiple sheets, converting each sheet into its own Markdown table.
  • Improved LLM Interaction: Eliminated the need for manual parsing logic in before_agent_callback for spreadsheet files, streamlining how LLMs interact with this data.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • pyproject.toml
    • Added openpyxl, pandas, odfpy, and xlrd as new dependencies for spreadsheet parsing.
    • Included tabulate dependency for converting dataframes to markdown tables.
  • src/google/adk/tools/load_artifacts_tool.py
    • Imported io and pandas for file handling and data manipulation.
    • Defined _SPREADSHEET_MIME_TYPES to include .xlsx, .xls, and .ods formats.
    • Implemented _parse_spreadsheet function to read spreadsheet bytes, process each sheet using pandas, and convert them into a combined Markdown string.
    • Integrated _parse_spreadsheet into _as_safe_part_for_llm to handle supported spreadsheet MIME types, transforming them into text parts for LLMs.
  • tests/unittests/tools/test_load_artifacts_tool.py
    • Added a new asynchronous unit test test_load_artifacts_parses_spreadsheet to verify that .xlsx files are correctly parsed into Markdown by the load_artifacts_tool.
Activity
  • The author verified the fix using a local test agent, confirming correct recognition of .xlsx, .xls, and .ods files.
  • Unit tests were updated, and all unit tests passed locally.
  • Manual end-to-end tests were performed, demonstrating the tool's ability to read and process data from various spreadsheet formats, including multi-sheet files.
  • The author provided screenshots illustrating the successful parsing of .xlsx, .xls, and .ods files into Markdown.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Feb 10, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great enhancement, adding support for parsing common spreadsheet formats (.xlsx, .xls, .ods) into Markdown within the load_artifact_tool. The implementation using pandas is a solid approach. My feedback focuses on a few areas for improvement: managing the new heavy dependencies by making them optional, refining the implementation for better clarity and error handling, and significantly strengthening the unit tests to cover all newly supported file types and improve assertion robustness.

Comment on lines 186 to 244
async def test_load_artifacts_parses_spreadsheet():
"""Spreadsheet artifacts are parsed into markdown."""
artifact_name = 'test.xlsx'

import pandas as pd
import io

df = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']})
output = io.BytesIO()
# Use openpyxl as engine since it is in deps
with pd.ExcelWriter(output, engine='openpyxl') as writer:
df.to_excel(writer, sheet_name='Sheet1', index=False)
xlsx_bytes = output.getvalue()

artifact = types.Part(
inline_data=types.Blob(
data=xlsx_bytes,
mime_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
)

tool_context = _StubToolContext({artifact_name: artifact})
llm_request = LlmRequest(
contents=[
types.Content(
role='user',
parts=[
types.Part(
function_response=types.FunctionResponse(
name='load_artifacts',
response={'artifact_names': [artifact_name]},
)
)
],
)
]
)

await load_artifacts_tool.process_llm_request(
tool_context=tool_context, llm_request=llm_request
)

artifact_part = llm_request.contents[-1].parts[1]
assert artifact_part.inline_data is None

# Check for Markdown table content
# We expect something like:
# ### Sheet: Sheet1
#
# | col1 | col2 |
# | :--- | :--- |
# | 1 | a |
# | 2 | b |

assert "Sheet1" in artifact_part.text
assert "col1" in artifact_part.text
assert "col2" in artifact_part.text
assert "1" in artifact_part.text
assert "a" in artifact_part.text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The new test only validates parsing for .xlsx files. Since this change also adds support for .xls and .ods files, it's crucial to add test cases for these formats as well. This will ensure that the required dependencies (xlrd, odfpy) are correctly integrated and will prevent future regressions. Consider using pytest.mark.parametrize to test all supported spreadsheet types with a single test function.

n-issei-777 and others added 3 commits February 11, 2026 12:04
Delete mime_type parameter within the _parse_spreadsheet function.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ryanaiagent ryanaiagent self-assigned this Feb 11, 2026
@ryanaiagent
Copy link
Collaborator

Hi @n-issei-777 , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
Can you open a CL instead of PR for this request. Closing this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants